*************************
**** Summary Stats ******
*************************
clear all
set more off
use "/Users/yasenov/Desktop/replication package/master.dta"

bysort classroom student_id: gen unique_student = _n == 1
egen term = group(year sem)

/* Panel A: student level */
preserve
collapse male age native_eth prescore, by(student_id)
tabstat male age native_eth prescore, stat(mean sd co) columns(stat)
restore
 
/* Panel B: classroom level */
preserve
collapse (sum) unique_student (mean) grade starttime stem, by(classroom)
tabstat unique_student stem starttime grade, stat(mean sd co)  columns(stat)   // although grade is standardized later 
restore

/* Panel C: student-classroom level */
preserve
collapse grade receiveZero zGradeConditional, by(student_id classroom)
tabstat receiveZero grade zGradeConditional, stat(mean sd semean co) columns(stat)
restore

/* Panel D: student-term level */
preserve
collapse starttime SDstarttime IQRstarttime, by(student_id term)
tabstat starttime SDstarttime IQRstarttime, stat(mean sd semean co) columns(stat)
restore
